package com.sunjob.mrotech.controller;

import com.sunjob.common.domain.tech.Fault;
import com.sunjob.common.mroAnno.ControllerLog;
import com.sunjob.common.mroAnno.LogModuleType;
import com.sunjob.common.result.Result;
import com.sunjob.mrotech.server.FaultServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author tlj
 * @Date 2022/8/5 14:30
 * @PackageName:com.sunjob.mrotech.controller
 * @ClassName: FaultController
 * @Description: TODO
 * @Version 1.0
 */
@Api(tags = "故障字典")
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
public class FaultController {
    @Autowired
    FaultServer faultServer;

    @ApiOperation("故障字典模糊查询")
    @GetMapping("/faultqueryall")
    public Result faultqueryall(@RequestParam("fault_phenomenon") String fault_phenomenon){
       return faultServer.faultqueryall(fault_phenomenon);
    }

    @ApiOperation("根据构型类型查询")
    @GetMapping("/selectfault")
    public Result selectfault(@RequestParam("configuration_id") String configuration_id){
        return faultServer.selectfault(configuration_id);
    }

    @ApiOperation("查询某一个故障")
    @GetMapping("/cxfault")
    public Result cxfault(@RequestParam("id") Long id){
        return faultServer.cxfault(id);
    }

    @ApiOperation("故障字典新增")
    @ControllerLog(LogModuleType.TECHNOLOGY)
    @PostMapping("/insertfault")
    public Result insertfault(@RequestBody Fault fault){
        return faultServer.insertfault(fault);
    }

    @ApiOperation("故障字典修改")
    @ControllerLog(LogModuleType.TECHNOLOGY)
    @PostMapping("/upfault")
    public Result upfault(@RequestBody Fault fault){
        return faultServer.upfault(fault);
    }

    @ApiOperation("故障字典删除")
    @ControllerLog(LogModuleType.TECHNOLOGY)
    @GetMapping("/delfault")
    public Result delfault(@RequestParam("id") Long id){
        return faultServer.delfault(id);
    }
}
